#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;

const int N = 110;

stack<char> st1,st2;

int main(){
	string s;
	cin >> s;
	for(int i = s.size()-1;i >= 0;){
		if(s[i] == ')'){
			st2.push(s[i]);
			i--;
			if(s[i] == '('){
				st2.push(s[i]);
				i--;
			}
			else{
				st2.push('(');
			}
		}
		else if(s[i] == ']'){
			st2.push(s[i]);
			i--;
			if(s[i] == '['){
				st2.push(s[i]);
				i--;
			}
			else{
				st2.push('[');
			}
		}
		else if(s[i] == '('){
			st2.push(')');
			st2.push('(');
			i--;
		}
		else if(s[i] == '['){
			st2.push(']');
			st2.push('[');
			i--;
		}
	}
	while(st2.size()){
		cout << st2.top();
		st2.pop();
	}
	return 0;
} 
